<template>
	<view class="produce_add">
		<view class="close" @click="$emit('close')">
			<image :src="`${baseImageUrl}/common/close1.png`"></image>
		</view>
		<view class="title">
			<view>
				<image :src="`${baseImageUrl}/common/zw.png`"></image>
				<text>补充耐久</text>
				<image :src="`${baseImageUrl}/common/zw.png`"></image>
			</view>
		</view>
		<view class="cover">
			<image :src="cover"></image>
		</view>
		<!-- <view class="number">
			<view class="icon" @click="reduce">
				<image :src="`${baseImageUrl}/common/js.png`"></image>
			</view>
			<input type="text" placeholder="请输入耐久度数量" v-model="number" @input="change">
			<view class="icon" @click="add">
				<image :src="`${baseImageUrl}/common/zj.png`"></image>
			</view>
		</view> -->
		<view class="btn_view">
			<view class="cancel" @click="$emit('close')">取消</view>
			<view class="confirm" @click="submit">确认</view>
		</view>
	</view>
</template>

<script>
	import {
		industrySupplement
	} from '@/request/api.js';
	export default {
		props: {
			id: {
				type: [Number, String],
				default: ""
			},
			cover: {
				type: String,
				default: ""
			}
		},
		data() {
			return {
				number: ""
			}
		},
		methods: {
			reduce() {
				if (this.number == 0) {
					this.$u.toast("不可减少了");
					return false;
				}
				this.number--
			},
			add() {
				this.number++;
			},
			change(e) {
				e.target.value = e.target.value.replace(/^0|[^\d]|[.]/g, "");
				this.$nextTick(() => {
					this.number = e.target.value;
				});
			},
			async submit() {
				await industrySupplement({
					industry_id: this.id,
					// number: this.number
				});
				this.$u.toast("操作成功");
				setTimeout(() => {
					this.$emit('success');
				}, 1000);
			}
		}
	}
</script>

<style scoped lang="scss">
	.produce_add {
		width: 630rpx;
		height: 630rpx;
		padding: 42rpx 0 52rpx;
		box-sizing: border-box;
		background: url(#{$baseImageUrl}/bg/630_630.png) no-repeat;
		background-size: 100% 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		position: relative;

		.close {
			width: 122rpx;
			height: 122rpx;
			position: absolute;
			right: 0rpx;
			top: 0rpx;
			transform: translate(50rpx, -50rpx);
			z-index: 2;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.title {
			display: flex;
			justify-content: center;
			align-items: center;

			view {
				height: 30rpx;
				display: flex;
				align-items: center;

				image {
					width: 30rpx;
					height: 30rpx;
				}

				text {
					color: #494338;
					font-size: 42rpx;
					font-weight: 400;
					font-family: LiSu;
					margin: 0 10rpx;
				}
			}
		}

		.cover {
			width: 240rpx;
			height: 240rpx;
			background: url(#{$baseImageUrl}/bg/372_372.png) no-repeat;
			background-size: 100% 100%;
			display: flex;
			justify-content: center;
			align-items: center;

			image {
				width: 200rpx;
				height: 200rpx;
				// border-radius: 50%;
			}
		}

		.number {
			width: 100%;
			height: 80rpx;
			padding: 0 35rpx;
			// margin: 36rpx 0 60rpx;
			box-sizing: border-box;
			display: flex;

			.icon {
				width: 80rpx;
				height: 80rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			input {
				flex: 1;
				height: 80rpx;
				text-align: center;
				color: #494338;
				font-size: 28rpx;
				font-weight: 400;
				font-family: SimSun;
				border-radius: 10rpx;
				box-shadow: 2rpx -1rpx 10rpx 0px rgba(3, 0, 0, 0.2);
				background: #C0B5B6;
			}
		}

		.btn_view {
			width: 100%;
			display: flex;
			justify-content: center;

			view {
				width: 210rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				color: #FFFFFF;
				font-size: 30rpx;
				font-weight: 400;
				margin: 0 40rpx;
			}

			.cancel {
				background: url(#{$baseImageUrl}/common/btn2.png) no-repeat;
				background-size: 100% 100%;
			}

			.confirm {
				background: url(#{$baseImageUrl}/common/btn.png) no-repeat;
				background-size: 100% 100%;
			}
		}
	}
</style>